﻿using RXY_Mall.Data.Mapping;
using RXY_Mall.Domain;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Reflection;

namespace RXY_Mall.Data
{
    public class RXY_MallContext : DbContext
    {


        public RXY_MallContext()
            : base("name=RXY_MallContext")
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            var typesToRegister = Assembly.GetExecutingAssembly().GetTypes()
            .Where(type => !String.IsNullOrEmpty(type.Namespace))
            .Where(type => type.BaseType != null && type.BaseType.IsGenericType &&
                type.BaseType.GetGenericTypeDefinition() == typeof(NopEntityTypeConfiguration<>));
            foreach (var type in typesToRegister)
            {
                dynamic configurationInstance = Activator.CreateInstance(type);
                modelBuilder.Configurations.Add(configurationInstance);
            }

            //modelBuilder.Conventions.Add(new DecimalPrecisionAttributeConvention());
            base.OnModelCreating(modelBuilder);
        }

        #region 基础
        /// <summary>
        /// 短信
        /// </summary>
        public virtual DbSet<gw_base_sms> gw_base_smses { get; set; }
        /// <summary>
        /// app版本
        /// </summary>
        public virtual DbSet<gw_base_app_version> gw_base_app_versions { get; set; }
        /// <summary>
        /// 上传文件
        /// </summary>
        public virtual DbSet<gw_base_file> gw_base_files { get; set; }
        /// <summary>
        /// 地址
        /// </summary>
        public virtual DbSet<gw_base_area> gw_base_areas { get; set; }
        /// <summary>
        /// 商品类型
        /// </summary>
        public virtual DbSet<gw_base_goods_type> gw_base_goods_types { get; set; }
        /// <summary>
        /// 广告类型
        /// </summary>
        public virtual DbSet<gw_base_advert_type> gw_base_advert_types { get; set; }
        /// <summary>
        /// 物流公司
        /// </summary>
        public virtual DbSet<gw_base_logistics> gw_base_logistics { get; set; }
        /// <summary>
        /// 品牌
        /// </summary>
        public virtual DbSet<gw_base_brand> gw_base_brands { get; set; }

        #endregion

        #region 用户
        /// <summary>
        /// 用户
        /// </summary>
        public virtual DbSet<gw_user> gw_users { get; set; }
        /// <summary>
        /// 第三方登录
        /// </summary>
        public virtual DbSet<gw_user_third> gw_user_thirds { get; set; }
        /// <summary>
        /// 收货地址
        /// </summary>
        public virtual DbSet<gw_user_address_book> gw_user_address_books { get; set; }
        /// <summary>
        /// 用户优惠券
        /// </summary>
        public virtual DbSet<gw_user_coupon> gw_user_coupons { get; set; }
        /// <summary>
        /// 用户支付密码
        /// </summary>
        public virtual DbSet<gw_user_password> gw_user_passwords { get; set; }
        /// <summary>
        /// 用户支付密码日志
        /// </summary>
        public virtual DbSet<gw_user_password_log> gw_user_password_logs { get; set; }
        
        /// <summary>
        /// 身份认证
        /// </summary>
        public virtual DbSet<gw_user_certification> gw_user_certifications { get; set; }
        /// <summary>
        /// 用户收藏
        /// </summary>
        public virtual DbSet<gw_user_collection> gw_user_collections { get; set; }
        /// <summary>
        /// 用户VIP
        /// </summary>
        public virtual DbSet<gw_user_rule> gw_user_rules { get; set; }

        /// <summary>
        /// 用户权益图片
        /// </summary>
        public virtual DbSet<gw_user_rule_picture> gw_user_rule_pictures { get; set; }
        /// <summary>
        /// 用户升级
        /// </summary>
        public virtual DbSet<gw_user_upgrade> gw_user_upgrades { get; set; }

        #endregion

        #region 金融
        /// <summary>
        /// 用户财富
        /// </summary>
        public virtual DbSet<gw_finance_property> gw_finance_properties { get; set; }
        /// <summary>
        /// 财富日志
        /// </summary>
        public virtual DbSet<gw_finance_property_log> gw_finance_property_logs { get; set; }
        /// <summary>
        /// 用户银行卡
        /// </summary>
        public virtual DbSet<gw_finance_bankcard> gw_finance_bankcards { get; set; }
        /// <summary>
        /// 用户银行卡
        /// </summary>
        public virtual DbSet<gw_finance_withdraw> gw_finance_withdraws { get; set; }
        /// <summary>
        /// 补贴卡
        /// </summary>
        public virtual DbSet<gw_finance_redpacket_subsidy> gw_finance_subsidies { get; set; }
        /// <summary>
        /// 补贴卡
        /// </summary>
        public virtual DbSet<gw_finance_redpacket_subsidy_item> gw_finance_subsidy_items { get; set; }
        /// <summary>
        /// 红包
        /// </summary>
        public virtual DbSet<gw_finance_redpacket> gw_finance_redpackets { get; set; }
        /// <summary>
        /// 第三方支付
        /// </summary>
        public virtual DbSet<gw_finance_payment> gw_finance_payments { get; set; }
        /// <summary>
        /// 交易日志
        /// </summary>
        public virtual DbSet<gw_finance_trade_log> gw_finance_trade_logs { get; set; }
        /// <summary>
        /// 直接购买红包
        /// </summary>
        public virtual DbSet<gw_finance_redpacket_buy> gw_finance_redpacket_buys { get; set; }
        #endregion

        #region 商店
        /// <summary>
        /// 商家
        /// </summary>
        public virtual DbSet<gw_suppliers> gw_suppliers { get; set; }
        /// <summary>
        /// 店铺
        /// </summary>
        public virtual DbSet<gw_shop> gw_shops { get; set; }
        /// <summary>
        /// 店铺特性
        /// </summary>
        public virtual DbSet<gw_shop_property> gw_shop_propertys { get; set; }
        /// <summary>
        /// 商店 银行卡
        /// </summary>
        public virtual DbSet<gw_shop_bankcard> gw_shop_bankcards { get; set; }

        /// <summary>
        /// 店铺财务明细
        /// </summary>
        public virtual DbSet<gw_shop_finance_log> gw_shop_finance_logs { get; set; }

        /// <summary>
        /// 店铺结算
        /// </summary>
        public virtual DbSet<gw_shop_finance_settlement> gw_shop_finance_settlements { get; set; }

        /// <summary>
        /// 店铺提现
        /// </summary>
        public virtual DbSet<gw_shop_finance_withdrawal> gw_shop_finance_withdrawals { get; set; }

        /// <summary>
        /// 店铺待退款
        /// </summary>
        public virtual DbSet<gw_shop_finance_return> gw_shop_finance_returns { get; set; }
        /// <summary>
        /// 商家秘密
        /// </summary>
        public virtual DbSet<gw_shop_password> gw_shop_passwords { get; set; }

        /// <summary>
        /// 商店类别
        /// </summary>
        public virtual DbSet<gw_shop_category_mapping> gw_shop_category_mappings { get; set; }

        /// <summary>
        /// 商店品牌
        /// </summary>
        public virtual DbSet<gw_shop_brand_mapping> gw_shop_brand_mappings { get; set; }

        #endregion

        #region 商品
        /// <summary>
        /// 商品分类
        /// </summary>
        public virtual DbSet<gw_goods_category> gw_goods_categories { get; set; }
        /// <summary>
        /// 商品
        /// </summary>
        public virtual DbSet<gw_goods> gw_goods { get; set; }
        /// <summary>
        /// 商品收藏
        /// </summary>
        public virtual DbSet<gw_goods_collection> gw_goods_collections { get; set; }
        /// <summary>
        /// 商品属性
        /// </summary>
        public virtual DbSet<gw_goods_property> gw_goods_propertys { get; set; }
        /// <summary>
        /// 商品标签
        /// </summary>
        public virtual DbSet<gw_goods_tag> gw_goods_tags { get; set; }
        /// <summary>
        /// 商品评论
        /// </summary>
        public virtual DbSet<gw_goods_comment> gw_goods_comments { get; set; }
        /// <summary>
        /// 商品评论图片
        /// </summary>
        public virtual DbSet<gw_goods_comment_picture> gw_goods_comment_pictures { get; set; }
        /// <summary>
        /// 商品图片
        /// </summary>
        public virtual DbSet<gw_goods_picture> gw_goods_pictures { get; set; }
        /// <summary>
        /// 商品SKU
        /// </summary>
        public virtual DbSet<gw_goods_sku> gw_goods_skus { get; set; }
        /// <summary>
        /// 商品规格
        /// </summary>
        public virtual DbSet<gw_goods_spec> gw_goods_specs { get; set; }
        /// <summary>
        /// 商品规格值
        /// </summary>
        public virtual DbSet<gw_goods_spec_value> gw_goods_spec_values { get; set; }
        /// <summary>
        /// 助力免单
        /// </summary>
        public virtual DbSet<gw_goods_rule_free> gw_goods_rule_frees { get; set; }
        /// <summary>
        /// 拼手气
        /// </summary>
        public virtual DbSet<gw_goods_rule_group> gw_goods_rule_groups { get; set; }
        /// <summary>
        /// 商品服务
        /// </summary>
        public virtual DbSet<gw_goods_service> gw_goods_services { get; set; }
        /// <summary>
        /// 商品搜索
        /// </summary>
        public virtual DbSet<gw_goods_search> gw_goods_searches { get; set; }
        /// <summary>
        /// 商品浏览
        /// </summary>
        public virtual DbSet<gw_goods_view> gw_goods_views { get; set; }
        #endregion

        #region 营销
        /// <summary>
        /// 促销广告
        /// </summary>
        public virtual DbSet<gw_marketing_banner> gw_marketing_banners { get; set; }

        /// <summary>
        /// 促销广告
        /// </summary>
        public virtual DbSet<gw_marketing_coupon> gw_marketing_coupons { get; set; }

        /// <summary>
        /// 促销商品
        /// </summary>
        public virtual DbSet<gw_marketing_goods> gw_marketing_goods { get; set; }

        /// <summary>
        /// 全返商品
        /// </summary>
        public virtual DbSet<gw_marketing_returned> gw_marketing_returneds { get; set; }

        /// <summary>
        /// 全返商品
        /// </summary>
        public virtual DbSet<gw_marketing_returned_item> gw_marketing_returned_items { get; set; }

        #endregion

        #region 购物车
        public virtual DbSet<gw_cart> gw_carts { get; set; }
        public virtual DbSet<gw_cart_history> gw_cart_histories { get; set; }
        #endregion

        #region 订单
        /// <summary>
        /// 订单
        /// </summary>
        public virtual DbSet<gw_order> gw_orders { get; set; }
        /// <summary>
        /// 订单地址
        /// </summary>
        public virtual DbSet<gw_order_address> gw_order_addresses { get; set; }
        /// <summary>
        /// 订单商品
        /// </summary>
        public virtual DbSet<gw_order_goods> gw_order_goods { get; set; }
        /// <summary>
        /// 拼单
        /// </summary>
        public virtual DbSet<gw_order_group> gw_order_groups { get; set; }
        /// <summary>
        /// 拼单用户
        /// </summary>
        public virtual DbSet<gw_order_group_user> gw_order_group_users { get; set; }
        /// <summary>
        /// 会员订单
        /// </summary>
        public virtual DbSet<gw_order_member> gw_order_members { get; set; }
        /// <summary>
        /// 会员订单支付
        /// </summary>
        public virtual DbSet<gw_order_member_payment> gw_order_member_payments { get; set; }
        /// <summary>
        /// 运单
        /// </summary>
        public virtual DbSet<gw_order_waybill> gw_order_waybills { get; set; }
        /// <summary>
        /// 退款单
        /// </summary>
        public virtual DbSet<gw_order_refund> gw_order_refunds { get; set; }
        /// <summary>
        /// 支付单
        /// </summary>
        public virtual DbSet<gw_order_payment> gw_order_payments { get; set; }
        #endregion

        #region 退换货
        /// <summary>
        /// 退换货单
        /// </summary>
        public virtual DbSet<gw_return> gw_returns { get; set; }
        /// <summary>
        /// 退换货请求
        /// </summary>
        public virtual DbSet<gw_return_request> gw_return_requests { get; set; }
        /// <summary>
        /// 退换货请求图片
        /// </summary>
        public virtual DbSet<gw_return_request_picture> gw_return_request_pictures { get; set; }
        /// <summary>
        /// 退换货供应商审核
        /// </summary>
        public virtual DbSet<gw_return_audit> gw_return_audits { get; set; }
        /// <summary>
        /// 退换货用户发货信息
        /// </summary>
        public virtual DbSet<gw_return_waybill> gw_return_waybills { get; set; }



        #endregion

        #region 消息
        public virtual DbSet<gw_message> gw_messages { get; set; }
        public virtual DbSet<gw_message_check> gw_message_checks { get; set; }
        public virtual DbSet<gw_message_rule_discount> gw_message_rule_discounts { get; set; }
        public virtual DbSet<gw_message_rule_order> gw_message_rule_orders { get; set; }
        public virtual DbSet<gw_message_rule_redpacket> gw_message_rule_redpackets { get; set; }
        public virtual DbSet<gw_message_rule_wallet> gw_message_rule_withdraws { get; set; }
        #endregion

        #region 设置
        public virtual DbSet<gw_setting> gw_settings { get; set; }
        #endregion

        #region 管理员
        public virtual DbSet<gw_manager> gw_managers { get; set; }
        public virtual DbSet<gw_manager_password> gw_manager_passwords { get; set; }
        public virtual DbSet<gw_manager_password_log> gw_manager_password_logs { get; set; }
        public virtual DbSet<gw_manager_log> gw_manager_logs { get; set; }
        public virtual DbSet<gw_manager_role> gw_manager_role { get; set; }
        public virtual DbSet<gw_manager_role_value> gw_manager_role_value { get; set; }

        #endregion

        #region 安全
        /// <summary>
        /// 安全URL
        /// </summary>
        public virtual DbSet<gw_security_url> gw_security_urls { get; set; }
        /// <summary>
        /// 登录记录
        /// </summary>
        public virtual DbSet<gw_security_login> gw_security_logins { get; set; }
        /// <summary>
        /// 登录IP
        /// </summary>
        public virtual DbSet<gw_security_ip> gw_security_ips { get; set; }
        /// <summary>
        /// 登录IP
        /// </summary>
        public virtual DbSet<gw_security_device> gw_security_devices { get; set; }
        #endregion

        #region 运费模板
        public virtual DbSet<gw_freight_template> gw_freight_templates { get; set; }
        public virtual DbSet<gw_freight_area_group> gw_freight_area_groups { get; set; }
        public virtual DbSet<gw_freight_distribution_area> gw_freight_distribution_areas { get; set; }

        #endregion

        #region 公司
        public virtual DbSet<gw_company> gw_companys { get; set; }
        
        #endregion

    }
}
